import request from "@/util/http";
import qs from "qs";

export default {
  //渲染页面接口
  gain(forms) {
    return request({
      method: "get",
      params: {
        _gp: "admin",
        _mt: "list",
        username: forms.input,
        page: forms.pageNo,
        limit: forms.pageSize
      }
    });
  },
  //新增管理员
  adduser(form, input) {
    console.log(form);
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin",
        _mt: "create",
        adminDTO: JSON.stringify({
          username: input,
          password: form.pwd,
          phone: form.number,
          realname: form.name,
          roleIds: form.rolelds
        })
      })
    });
  },
  //删除接口
  cancel(id) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin",
        _mt: "delete",
        id: id
      })
    });
  },
  //编辑角色
  compile(form) {
    return request({
      method: "post",
      data: qs.stringify({
        _gp: "admin",
        _mt: "update",
        adminDTO: JSON.stringify({
          username: form.username,
          password: form.pwd,
          phone: form.number,
          realname: form.name,
          roleIds: form.rolelds,
          id: form.id
        })
      })
    });
  }
};
